package com.andaily.web.controller.validator;

import com.andaily.domain.dto.thing.ThingDto;
import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

/**
 * @author Shengzhao Li
 */
public class ThingDtoValidator implements Validator {

    @Override
    public boolean supports(Class<?> clazz) {
        return ThingDto.class.equals(clazz);
    }

    @Override
    public void validate(Object target, Errors errors) {
        ValidationUtils.rejectIfEmpty(errors, "content", null, "内容不能为空");
    }
}
